<?php

use Phinx\Db\Adapter\MysqlAdapter;
use Phinx\Migration\AbstractMigration;

class CreateTenantRobotUserCertificateTable extends AbstractMigration
{
    public function up()
    {
        $this->table("tenant_robot_user_certificate", ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '租户机器人证书表'])
            ->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('active', 'integer', ['default' => 0, 'limit' => MysqlAdapter::INT_TINY, 'comment' => '激活状态 0未启用 1启用'])
            ->addColumn('app_key', 'char', ['default' => '', 'limit' => 36, 'comment' => '唯一标识每一个客户端(client),后端自动生成'])
            ->addColumn('app_secret', 'char', ['default' => '', 'limit' => 36, 'comment' => '用于指定客户端(client)的访问密匙,后端自动生成'])
            ->addColumn('user_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '用户id'])
            ->addColumn('tenant_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '租户id'])
            ->addColumn('tenant_user_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '租户用户id'])
            ->addColumn('created', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间'])
            ->addColumn('updated', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '更新时间'])
            ->addColumn('uuid', 'char', ['default' => '', 'limit' => 36, 'comment' => '全局唯一标识符'])
            ->save();
    }

    public function down()
    {
        $this->table("tenant_robot_user_certificate")->drop()->save();
    }
}
